package org.stwy.pro.asset;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.rap.common.persistence.IBaseDAO;

/**
 * 物业 DAO类
 */
/**
*版权信息 (c) RAP 保留所有权利.
*@author Rap.Codegen
*@Team RAP Team
*@Date 2015-4-4 17:05:42
*<p></p>
*
*@参与人：Rap.Codegen
*/
 
public interface AssetDAO extends IBaseDAO<AssetEntity, String> {
	
	@Query(" select max(a.theCode) from AssetEntity a")
	Long getLastCode();

	@Query(" select b from AssetEntity b where b.beginTs="
			+ "(select max(a.beginTs) from AssetEntity a where a.theCode = ?1)"
			+ " and b.theCode=?1 ")
	AssetEntity getLastByTheCode(Long code);
	
	@Query(" select b from AssetEntity b where b.status=1 "
			+ " and b.theCode=?1 ")
	AssetEntity getValidRecordByCode(Long code);

	@Query(" select b from AssetEntity b where b.recordDate="
			+ "(select max(a.recordDate) from AssetEntity a where a.theCode = ?1)"
			+ " and b.theCode=?1 order by b.beginTs desc")
	List<AssetEntity> getLastChangeByTheCode(Long theCode);
	
}
